"use strict";
var chai = require("chai");
var test = require("./Dist/DistSurveySimulateTest");
var DistComSimulate_1 = require('./../Model/Dist/DistComSimulate');
var should = chai.should();
var serialport = require('serialport');
var expect = chai.expect;
var portName = "";
before((done) => {
    portName.length === 0 && serialport.list(function (err, list) {
        var reg = /COM\d/;
        for (let item of list) {
            if (reg.test(item.comName)) {
                portName = item.comName;
                break;
            }
            else {
                console.log('nomatch');
            }
        }
        done();
    });
});
describe('测距仪', function () {
    describe('#串口模拟测试,验证测距仪代码的可行性', function () {
        this.timeout(1000 * 60);
        it('应该能够在控制台输出模拟的测距成果', function (done) {
            test.simulateTest(portName).then(function () {
                done();
            });
        });
    });
    describe('#模拟一个测距仪测距', function () {
        this.timeout(1000 * 5);
        it('应该能够返回一个模拟出来的距离', function (done) {
            var com = new DistComSimulate_1.default(portName);
            setTimeout(function () {
                com.survey(34).then(function (data) {
                    com.close();
                    data.should.be.a('number');
                    done();
                });
            }, 800);
        });
    });
});
